﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Proggy.Web.Cms.Context;

namespace Proggy.Web.Cms.Sections.Core
{
    public class MembershipAndGroupsSection : ISection
    {

        public string ControllersNamespace
        {
            get { return "Proggy.Web.Cms.Controllers.BackEnd"; }
        }

        public SectionItem RootItem
        {
            get
            {
                return new SectionItem
                {
                    DisplayText = "Membership and groups",
                    ActionName = "Index",
                    RouteValues = new { controller = "MembershipAndGroups" },
                    IsHeadingOnly = true
                };
            }
        }

        public List<SectionItem> Items
        {
            get
            {
                // get mode
                var isFormsAuth = MembershipContext.CurrentAuthenticationMode == System.Web.Configuration.AuthenticationMode.Forms;

                // start list
                var list = new List<SectionItem>();

                // add first
                list.Add(new SectionItem
                    {
                        ActionName = "Members",
                        DisplayText = "Members",
                        RouteValues = new { controller = "MembershipAndGroups" }
                    });

                // check
                if (isFormsAuth)
                {
                    list.Add(new SectionItem
                       {
                           ActionName = "MemberNew",
                           DisplayText = "New member",
                           RouteValues = new { controller = "MembershipAndGroups" }
                       });
                }

                // add standard
                list.Add(new SectionItem
                {
                    ActionName = "Groups",
                    DisplayText = "Groups",
                    RouteValues = new { controller = "MembershipAndGroups" }
                });

                // add standard
                list.Add(new SectionItem
                {
                    ActionName = "GroupNew",
                    DisplayText = "New group",
                    RouteValues = new { controller = "MembershipAndGroups" }
                });


                // check
                if (isFormsAuth)
                {
                    list.Add(
                    new SectionItem
                    {
                        ActionName = "ChangePassword",
                        DisplayText = "Change your password",
                        RouteValues = new { controller = "MembershipAndGroups" }
                    });
                }

                return list;
            }
        }


        public int OrderInNav
        {
            get { return -7001; }
        }
    }
}
